package com.ewzj.bigdata.mvp.model;

import android.app.Application;

import com.ewzj.bigdata.app.utils.Apputils;
import com.ewzj.bigdata.mvp.model.api.Api;
import com.ewzj.bigdata.mvp.model.api.service.CommonService;
import com.ewzj.bigdata.mvp.model.entity.resbean.BaseJson;
import com.ewzj.bigdata.mvp.model.entity.resbean.UserBean;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;

import javax.inject.Inject;

import com.ewzj.bigdata.mvp.contract.EditProfileContract;

import io.reactivex.Observable;


@ActivityScope
public class EditProfileModel extends BaseModel implements EditProfileContract.Model {
    private Gson mGson;
    private Application mApplication;
    private CommonService service;
    @Inject
    public EditProfileModel(IRepositoryManager repositoryManager, Gson gson, Application application) {
        super(repositoryManager);
        this.mGson = gson;
        this.mApplication = application;
        this.service=repositoryManager.obtainRetrofitService(CommonService.class);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
        this.service=null;
    }

    @Override
    public Observable<BaseJson> updateUserInfo(UserBean userBean) {
        String json=mGson.toJson(userBean);
        return service.getDataFromService(Apputils.getFromatUrl(Api.UPDATE_USERINFO),Apputils.json2Body(json));
    }


}